#editsToRYears.py


import os
import sys

def main():

	path = sys.argv[1]
	files = os.listdir(path)
	yearDict = {}

	for nsfile in files:
		f = open(path+nsfile, "r")
		numList = []
		for line in f:
			
			if line[:5] == "Stats":
				pieces = line.replace(' ','').split('/')
				startyear = pieces[-1].strip()[-8:-4]
				name = pieces[-1][:-9]
					
			elif line[:5] <> "TOTAL":	
				tokens = line.split(' ')			
				offset = int(startyear)+int(tokens[0])
				if offset not in yearDict:
					yearDict[offset] = 0
				print tokens[0]
				yearDict[offset] += int(tokens[1].replace('\n',''))

	for key in sorted(yearDict.keys()):
		
		numList.append(str(yearDict[key]))

	printable(numList,name)

def printable(aList,fileName):
	print fileName + " <- c(" + ",".join(aList) + ')'

main()
